package com.jp.knowledge.my.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;

import com.jp.knowledge.R;
import com.jp.knowledge.adapter.team_circle.TeamCircleAdapter;
import com.jp.knowledge.comm.JpApplication;
import com.jp.knowledge.model.TeamCircleModel;
import com.jp.knowledge.my.base.RecycleVHolder;
import com.jp.knowledge.util.TimeUtil;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by 528787067@qq.com on 2017/5/9.
 */

public class FeedbackAdapter extends TeamCircleAdapter {

    private DateFormat dateFormat;

    public FeedbackAdapter(Context context, @NonNull List<TeamCircleModel> list) {
        super(context, list);
        dateFormat = new SimpleDateFormat("MM月dd日 hh:mm");
    }

    @Override
    public void onBind(RecycleVHolder holder, int position) {
        super.onBind(holder, position);
        holder.get(R.id.team_circle_private).setVisibility(View.GONE);
        holder.get(R.id.team_circle_chat).setVisibility(View.GONE);
        holder.get(R.id.team_circle_pay_reward).setVisibility(View.GONE);
        holder.get(R.id.team_circle_delete).setVisibility(View.VISIBLE);

        TextView sendTimeTv = holder.getTextView(R.id.team_circle_time);
        try {
            sendTimeTv.setText(dateFormat.format(mList.get(position).getCreatetime()));
            sendTimeTv.setVisibility(View.VISIBLE);
        } catch (Exception e){
            sendTimeTv.setVisibility(View.GONE);
        }
    }

    @Override
    protected void setLevel(View levelView, int type, int level) {
        levelView.findViewById(R.id.team_circle_level_icon).setVisibility(View.GONE);
        TextView levelText = (TextView) levelView.findViewById(R.id.team_circle_level_text);
        levelText.setVisibility(View.VISIBLE);
        if(level == 1){
            levelText.setText("反馈");
            levelText.setTextColor(mContext.getResources().getColor(R.color.orange));
        } else if(level == 2){
            levelText.setText("纠错");
            levelText.setTextColor(mContext.getResources().getColor(R.color.google_red));
        } else{
            levelText.setVisibility(View.GONE);
        }
    }

    @Override
    public void onClick(View v) {
        if(v.getId() == R.id.team_circle_more){
            if(this.viewClickListener != null)
                this.viewClickListener.onCommentClick((int)v.getTag());
        } else {
            super.onClick(v);
        }
    }
}
